﻿using System;
using System.Collections.Generic;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTMemberOrElemInits : List<ASTMemberOrElemInit>
    {
        public override string ToString()
        {
            return Strings.joinobjs (", ", this);
        }
    }

    public class ASTMemberOrElemInit
    {
        //
    }

    public class ASTMemberOrElemInitNormal : ASTMemberOrElemInit
    {
        public string                  ident   { get; set; }
        public ASTExpr                 expr    { get; set; }
        public ASTObjectOrCollecInit   oci     { get; set; }

        public override string ToString()
        {
            if (expr != null)
                return ident + " = " + expr;
            else
                return ident + " = " + oci;
        }
    }

    public class ASTMemberOrElemInitArgs : ASTMemberOrElemInit
    {
        public readonly ASTArguments args = new ASTArguments();

        public override string ToString()
        {
            if (args.Count == 1)
                return args[0].ToString();
            else
                return "{" + args + "}";
        }
    }
}
